home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
pubdom.tar
/
pubdom
/
rbj
/
geom
< prev
next >
Wrap
Text File
|
1990-05-09
|
4KB
|
79 lines
%%HP: T(3)A(D)F(.);
@ GEOM Geometric, Dimension Programs
@ RBJ 5/09/90 Extracted from HP28. Improved Comments, Used Implicit
@ Numeric to String Conversion, RFR speeded up: Used
@ explicit divide and swap vs C->R stuff
@
DIR
@
@ Functions to Display Feet Inch and Fraction
@
DF \<< @ Number in decimal feet
DUP tFIF "\010" +
1 DISP 1 FREEZE \>>
INFF \<< @ For number in decimal inches
DUP 12 / @ Copy to remain, convert to feet,
DF DROP \>> @ Run DF, DROP Feet
CFIF \<< @ X and Y of complex pair (Feet)
DUP C\->R SWAP @ Copy to Remain, Do X first
tFIF "\010" + @ Display X on L1, Clear Line 2
"X= " SWAP + 1 DISP
tFIF "Y= " SWAP + 2 DISP @ Display Y on L2
1 FREEZE \>>
P2AB \<< @ Given two (X,Y) points, returns (a,b) : the terms of the
@ equation of the line between the two points: y = ax +b.
DUP ROT - C\->R SWAP / DUP
ROT C\->R ROT ROT * - R\->C \>>
EQXY \<< @ Given the equation of two lines (a,b) on the stack,
@ returns the intersection point (X,Y).
OVER - C\->R NEG SWAP / ABXY \>>
ABXY \<< @ Given an equation of a line (a,b) and an X coordinate,
@ returns the point (X,Y) on the line.
SWAP C\->R SWAP 3 PICK * + R\->C \>>
FRC 16 @ Fractional Precision such as
@ 8, 16,or 32 (User Adjustable)
@ Guts of Program: Replaces Top of Stack number in decimal feet with
@ character string representation in feet inches and fraction.
tFIF \<<
RCLF STD @ Save Flags, set STD mode
SWAP ABS 12 * @ Convert to POSITIVE Inches
FRC * 0 RND @ Round to Integral FRCs
FRC MD @ X frcs, N inch
12 MD @ X frc, Y inch, Z feet
"' " + SWAP @ Implied Conversion: "Feet' "
+ SWAP @ "Feet' Inch"
FRC SWAP FRS + @ Add Fraction String
34 CHR + @ Add Quote for Inch
SWAP STOF \>> @ Restore Flags
MD \<< @ Integer Divide and Remainder
MOD LASTARG / IP \>> @ Num Denom -> Rem Quo
FRS \<< @ Convert fraction to a string.
DUP @ Denom Numer
IF 0 == @ Null string if Numer = 0
THEN DROP2 ""
ELSE RFR @ Reduce fraction
"/" + @ Denom "Numer/"
SWAP + @ "Numer/Denom"
"-" SWAP + @ "-Numer/Denom"
END \>>
RFR \<< @ Reduces to lowest fraction
IF DUP 2 MOD NOT @ (Numer in 1, Denom in 2)
THEN 2 / SWAP 2 / SWAP @ Divide both by 2 if Numer EVEN
RFR @ Recursion!
END \>>
END